package com.yuebook.smartrpc.framework.cluster.impl;

import com.yuebook.smartrpc.framework.cluster.ClusterStrategy;
import com.yuebook.smartrpc.framework.model.ProviderService;
import java.util.List;
import org.apache.commons.lang3.RandomUtils;

/**
 * @author honglei
 * @date 2018/11/20 上午10:13
 */
public class RondomClusterStrategyImpl implements ClusterStrategy {

    @Override
    public ProviderService select(List<ProviderService> providerServices) {
        int max = providerServices.size();
        int index = RandomUtils.nextInt(0, max-1);
        return providerServices.get(index);
    }
}
